package com.jeeplus.common.utils;    /**
 * @title: SqlUtils
 * @projectName jeeplus
 * @description: TODO
 * @author Administrator
 * @date 2019/8/1310:23
 */

import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SqlUtils {
    protected static Logger logger = LoggerFactory.getLogger(SqlUtils.class);

    public static String readScript(Class cls, String fileName) throws IOException {
        try {
            String path = Paths.get((new File(cls.getResource("/Script/").getPath() + fileName)).getAbsolutePath(), new String[0]).toString();
            if ((new File(path)).exists()) {
                return FileUtils.getFileContent(path);
            }

            System.out.println(path);
            logger.error(String.format("【%s】脚本文件不存在!", new Object[]{fileName}));

        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return "";
    }
}
